<!DOCTYPE html>
<html>
<head>
  <title>JS is Fun!</title>
</head>
<body>
  <script type="text/javascript">
  /* write a function to sum numbers, if no argument is provided
    default summing a range of 1..100 - write a second function
    called range to return that range of integers */
  

  function gen100(){
    let sum = [];
    for(let i = 0; i <= 100; i++){
      sum.push(i);
    }
    return sum;
  }
  function sum(numbers){
    // you code
    let res = 0;
    if(!numbers){
      numbers = gen100();
      console.log(numbers);
    }
    for(let n of numbers){
        res += n;
    }
    
    return res;
  }


  // test code
  // with argument
  let ages = [11, 18, 25, 17, 33];
  console.log(sum(ages)); // 104

  // without argument
  console.log(sum()); // 5050 default
  </script>
</body>
</html>
